package cn.sycoder.vo;

import cn.sycoder.utils.BaseStringUtils;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author 杨润发
 * @since 2024-10-20
 */
@Data
@ApiModel(value = "Product对象", description = "")
public class ProductVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty("产品名称")
    private String name;

    @ApiModelProperty("历史入库总量")
    private Integer inventorySum;

    @ApiModelProperty("库存值")
    private Integer inventory;

    @ApiModelProperty("出库总值")
    private Integer inventoryRemove;

    @ApiModelProperty("单位")
    private String unit;

    @ApiModelProperty("库房地址多个存储用 ，号隔开如： 库房，位置，位置编号")
    private String location;

    @ApiModelProperty("1告警0是正常")
    private Integer alarm;

    @ApiModelProperty("物件编号")
    private String code;

    @ApiModelProperty("警告值 库存值低于警告值告警提示")
    private Integer alarmValue;

    @ApiModelProperty("型号")
    private String type;

    @ApiModelProperty("产品图片地址")
    private String img;

    @ApiModelProperty("显示一张图片")
    private String imgPath;

    @ApiModelProperty("显示多张图片")
    private List<String> imgPaths;

    @ApiModelProperty("状态 1开启，0删除")
    private Integer statusCode;

    // 设置图片显示
    public void setImg(String img) {
        List<String> ret = BaseStringUtils.handlerStrToList(img);
        if (ret.size() > 0) {
            this.imgPath = ret.get(0);
        } else {
            // 根据业务逻辑处理这种情况，比如设置默认值
            this.imgPath = "";
        }
        this.imgPaths = ret;
        this.img = img;
    }

    // 设置产品具体位置
    public void setLocation(String location) {
        List<String> ret = BaseStringUtils.handlerStrToList(location);
        if (ret.size() > 0) {
            this.storeHouse = ret.get(0);// 获取逗号分割后左边的值
            this.site = ret.get(1);// 获取逗号分割后右边的值
        } else {
            // 根据业务逻辑处理这种情况，比如设置默认值
            this.storeHouse = "";
            this.site = "";
        }
        this.location = location;
    }

    @ApiModelProperty("创建用户")
    private String createUser;

    // 自动填充
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    @ApiModelProperty("创建时间")
    private Date createTime;

    @ApiModelProperty("更新人")
    private String updateUser;

    // 自动填充
    @TableField(value = "update_time", fill = FieldFill.UPDATE)
    @ApiModelProperty("更新时间")
    private Date updateTime;

    @ApiModelProperty("库房地址")
    private String storeHouse;

    @ApiModelProperty("具体位置")
    private String site;


}
